Learn SQL

Website Reference

Database ‘Hospital’

Easy

SELECT first_name, last_name, gender FROM patients WHERE gender = 'M';
SELECT first_name, last_name FROM patients WHERE allergies is null;
SELECT first_name FROM patients WHERE first_name LIKE 'C%';
-- other solution SELECT first_name FROM patients WHERE substring(first_name, 1, 1) = 'C';
SELECT first_name, last_name FROM patients WHERE weight between 100 and 120;
-- other solution SELECT first_name, last_name FROM patients WHERE weight >= 100 AND weight <= 120;
UPDATE patients SET allergies = 'NKA' WHERE allergies is null; --- display the patients table to check results SELECT * FROM patients;

Medium

Hard